//Busquedas x Vias
function busqVias(){
	var busq = $("#txtbusq").val();
	var tipBusq = $("#cbotipbusq").val(); 
	var imagen=urljs+"images/loading.gif";
	
	if (busq=='' || busq.length<3){
		alert("No ha ingresado suficientes caracteres para filtro a buscar.");
	}
	else{
		if (tipBusq==9999999999){
			alert("Seleccione el Tipo de Busqueda");
		}
		else{
			$.ajax({	
				dataType: "html",
				type: "POST",
				url: urljs + "index.php/admtribut/busqviasgeneral",	
				data: "busq="+busq+
						"&tipBusq="+tipBusq,
						
				beforeSend: function(){
				$("#recuento").show();
				$("#Pagination").html("");
				$("#total").html('0');
				$("#locategridresult").html("<p style='margin-top:50;'><center><h3>Procesando</h3><img src="+imagen+"></center></p>");
				
				},
				success: function(requestData) {
					$("#locategridresult").html(requestData);
					
				},
				error: function(requestData, strError, strTipoError) {
					$("#Pagination").html("");
				    $("#locategridresult").html("Error: Disculpe las molestias intente cargar de nuevo.");
				}
			});			
		}
		
	}
	
}

function PagesViasPredios(page_index, jq){
	var items_per_page = $("#items_per_page").val();
	var max_elem = Math.min((page_index+1) * items_per_page, members.length);
	var newcontent = "";

	newcontent =  '<table class="tabla">';
	newcontent += '<thead>';
	newcontent += '<tr>';
	newcontent += '<th width="50px">Cod.Via</th>';
	newcontent += '<th width="50px">Tipo de Via</th>';
	newcontent += '<th width="470px">Nombre de Via</th>';
	newcontent += '<th width="30px valign="right">Predios</th>';
	newcontent += '</tr>';
	newcontent += '</thead>';
	
	for(var i=page_index*items_per_page; i<max_elem; i++){
		varbtn = "";
		
		if(members[i][0] > 0){
			//pintada = "#EEE8AA";
			varbtn = "<button id='btnPredios' value='" + members[i][0] + "'type='button' class='btninfo'"+ "onClick='mostrarpredios(this.value,\""+members[i][2]+"\",\""+members[i][1]+"\");'"+"></button>";
		}
			
		var cadcontentrow = "<tr>";
		cadcontentrow += '<td  align="center" width="50px">'+ members[i][0] +'</td>';
		cadcontentrow += '<td align="center" width="50px"> &nbsp;' + members[i][1] + '</td>';
		cadcontentrow += '<td width="470px">' + members[i][2] + '</td>';
		cadcontentrow +='<td align="center" width="30px">'+ varbtn+'</td>';
		cadcontentrow += '</tr>';

		newcontent += cadcontentrow;
	}

	newcontent += "</table>";

	$("#locategridresult").html(newcontent);
	$("#a_0").focus();
	return false;
	
}

function mostrarpredios(codvia,nomvia,tipvia)
{	  
	  $.lightbox(urljs+"index.php/admtribut/busprediosxvia?ccodvia="+codvia+"&nomvia="+nomvia+"&tipvia="+tipvia,{
		  "width":800,
		  "height":560,
	      "autoresize":true,
	      "modal":true		  
	  } );
	  
}

function reportesPrediosxVias(){
	var reporte = $("#cboreportesprexvias").val(); 
	var codvia=$("#hdcodvia").val();
		
	if (reporte==1){
		tipo="pdf";
		nombre="rptPrediosxVia";
		window.open(urlreportjs+"tipo="+tipo+"&reporte="+nombre+"&param=P_CCODVIA^"+codvia,"_blank");
	}
	else{
		if(reporte==2){
			tipo="excel";
			nombre="rptPrediosxViaExcel";
			window.open(urlreportjs+"tipo="+tipo+"&reporte="+nombre+"&param=P_CCODVIA^"+codvia,"_self");
		}	   
	}
}

function PagesViaPrediosWin(page_index, jq){
	var items_per_page = $("#items_per_page").val();
	var max_elem = Math.min((page_index+1) * items_per_page, members2.length);
	var newcontent = "";

	newcontent =  '<table class="tabla">';
	newcontent += '<thead>';
	newcontent += '<tr>';
	newcontent += '<th align="center" width="50px">Cod.Predio</th>';
	newcontent += '<th width="340px">Direcci&oacute;n de Predio</th>';
	newcontent += '<th align="center" width="50px">Cod. Contrib.</th>';
	newcontent += '<th width="340px">Nombre de Contribuyente</th>';
	newcontent += '</tr>';
	newcontent += '</thead>';
	
	for(var i=page_index*items_per_page; i<max_elem; i++){
			
		var cadcontentrow = "<tr class='cambio'>";
		cadcontentrow += '<td align="center" width="50px">'+ members2[i][0] +'</td>';
		cadcontentrow += '<td width="340px">' + members2[i][1] + '</td>';
		cadcontentrow += '<td width="50px">' + members2[i][2] + '</td>';
		cadcontentrow +='<td width="340px">'+ members2[i][3]+'</td>';
		cadcontentrow += '</tr>';

		newcontent += cadcontentrow;
	}

	newcontent += "</table>";

	$("#tbPredios").html(newcontent);
	$("#a_0").focus();
	return false;
	
}


